﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HotelSoft.HotelManagement_BUS;
using HotelSoft.HotelManagement_DTO;

namespace HotelSoft.HotelManagement_GUI
{
    public partial class frmReport_BaoCaoDoanhThu : Form
    {
        BaoCaoDoanhThuTheoLoaiBUS busDT = new BaoCaoDoanhThuTheoLoaiBUS();

        private int iThang, iNam, iQui, iloai;
        private string sngay;

        public string NGAY
        {
            get { return sngay; }
            set { sngay = value; }
        }

        public int LOAI
        {
            get { return iloai; }
            set { iloai = value; }
        }

        public int QUI
        {
            get { return iQui; }
            set { iQui = value; }
        }

        public int NAM
        {
            get { return iNam; }
            set { iNam = value; }
        }

        public int THANG
        {
            get { return iThang; }
            set { iThang = value; }
        }
        public frmReport_BaoCaoDoanhThu()
        {
            InitializeComponent();
        }

       

        private void Viewphong_Load(object sender, EventArgs e)
        {
            try
            {
                if (iloai == 0)
                {
                    DataTable dt = new DataTable();
                    docBaocaoDT = new rptReport_BaoCaoDoanhThu();
                    string s = Application.StartupPath + "\\rptReport_BaoCaoDoanhThu.rpt";
                    docBaocaoDT.Load(s);

                    THONGKE_NGAYDTO dto = new THONGKE_NGAYDTO();
                    dto.DATE = NGAY;
                    dt = busDT.BCDT_NGAY(dto);
                    docBaocaoDT.Database.Tables["command"].SetDataSource(dt);
                    Viewphong.ReportSource = docBaocaoDT;
                    docBaocaoDT.SetParameterValue("txtHinhthuc", "NGÀY: " + "(" +dto.DATE+ ")");
                }

                if (iloai == 1)
                {
                    DataTable dt = new DataTable();
                    docBaocaoDT = new rptReport_BaoCaoDoanhThu();
                    string s = Application.StartupPath + "\\rptReport_BaoCaoDoanhThu.rpt";
                    docBaocaoDT.Load(s);

                    THONGKE_THANGDTO dto = new THONGKE_THANGDTO();
                    dto.THANG = THANG;
                    dto.NAM = NAM;
                    dt = busDT.BCDT_THANG(dto);
                    docBaocaoDT.Database.Tables["command"].SetDataSource(dt);
                    Viewphong.ReportSource = docBaocaoDT;
                    docBaocaoDT.SetParameterValue("txtHinhthuc", "THÁNG " + "(" + dto.THANG + "/" + dto.NAM + ")"); 
                }

                if (iloai == 2)
                {
                    DataTable dtt = new DataTable();
                    docBaocaoDT = new rptReport_BaoCaoDoanhThu();
                    string s = Application.StartupPath + "\\rptReport_BaoCaoDoanhThu.rpt";
                    docBaocaoDT.Load(s);

                    THONGKE_QUIDTO dto = new THONGKE_QUIDTO();
                    dto.QUI = QUI;
                    dto.NAM = NAM;
                    dtt = busDT.BCDT_QUI(dto);
                    docBaocaoDT.Database.Tables["command"].SetDataSource(dtt);
                    Viewphong.ReportSource = docBaocaoDT;
                    docBaocaoDT.SetParameterValue("txtHinhthuc", "QUÍ " + dto.QUI + "/" + dto.NAM); 
                }

                if (iloai == 3)
                {
                    DataTable dt = new DataTable();
                    docBaocaoDT = new rptReport_BaoCaoDoanhThu();
                    string s = Application.StartupPath + "\\rptReport_BaoCaoDoanhThu.rpt";
                    docBaocaoDT.Load(s);

                    THONGKE_NAMDTO dto = new THONGKE_NAMDTO();
                    dto.NAM = NAM;
                    dt = busDT.BCDT_NAM(dto);
                    docBaocaoDT.Database.Tables["command"].SetDataSource(dt);
                    Viewphong.ReportSource = docBaocaoDT;
                    docBaocaoDT.SetParameterValue("txtHinhthuc", "NĂM " + dto.NAM); 
                }
            }
            catch 
            {
            }
           
        }

        private void btnClose_Click_1(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
